package cn.edu.scau.cmi.yanweijie.factory;


public class NormalFactory {
	public static void main(String arg[]) {
		Factory factory = new BeefMeatFactory();
		Meat meat = factory.createMeat();
		meat.description();
	}
	
	public static Meat normalCreateor(String FactoryName) {
		Factory factory = null;
		Meat meat = null;
		if(FactoryName.equals("BeefMeatFactory")) {
			factory = new BeefMeatFactory();
			meat = factory.createMeat();
			meat.description();
			return meat;
		}else if(FactoryName.equals("ChickenMeatFactory")) {
			factory = new ChickenMeatFactory();
			meat = factory.createMeat();
			meat.description();
			return meat;
		}else if(FactoryName.equals("PorkMeatFactory")) {
			factory = new PorkMeatFactory();
			meat = factory.createMeat();
			meat.description();
			return meat;
		}else {
			System.out.println("error occur!");
			return null;
		}
	
	}
}

abstract class Factory {
	static {
		System.out.println("using normal factory creating meat!");
	}
	public abstract Meat createMeat() ;
}

class BeefMeatFactory extends Factory {
	@Override
	public Meat createMeat() {
		Meat meat = new Beef(); 
		return meat;
	}
}


class PorkMeatFactory extends Factory {

	@Override
	public Meat createMeat() {
		// TODO Auto-generated method stub
		Meat meat = new Pork(); 
		return meat;
	}
	
}

class ChickenMeatFactory extends Factory {

	@Override
	public Meat createMeat() {
		// TODO Auto-generated method stub
		Meat meat = new Chicken(); 
		return meat;
	}
	
}